package jp.co.jmas.jmasvideo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jp.co.jmas.jmasvideo.dao.PMF;
import jp.co.jmas.jmasvideo.dao.UserData;

@SuppressWarnings("serial")
public class SetUserData extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		resp.setContentType("text/html");
		PrintWriter pw = resp.getWriter();

		// ユーザ登録
		ArrayList<String> list = new ArrayList<String>();
		list.add("y.matamura@gmail.com");
		list.add("mayowazu@ezweb.ne.jp");
		UserData user = new UserData("y.matamura@gmail.com", "y.matamura@gmail.com", list);

		ArrayList<String> list2 = new ArrayList<String>();
		list2.add("kohe5510@gmail.com");
		UserData user2 = new UserData("kohe5510@gmail.com", "kohe5510@gmail.com", list2);

		ArrayList<String> list3 = new ArrayList<String>();
		list3.add("kindergartencamera@gmail.com");
		UserData user3 = new UserData("kindergartencamera@gmail.com", "kindergartencamera@gmail.com", list3);

		PersistenceManager pm = PMF.get().getPersistenceManager();
		try {
			pm.makePersistent(user);
			pm.makePersistent(user2);
			pm.makePersistent(user3);
		} finally {
			pm.close();
		}

		pw.println("ok!");
	}
}
